<template>
  <div class="pdf-viewer">
    <iframe :src="pdfurl"
            width="100%"
            height="100%"></iframe>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pdfurl: '',
    }
  },
  methods: {},
  created() {},
  mounted() {
    let { url } = this.$route.query
    // 获取预览文件的完整接口地址，根据具体情况编写，反正path就是一个预览文件的接口地址
    // const path = this.$api.filePreview(id)
    // const url =
    //   'https%3A%2F%2Fchcms.xinxinqushi.com%2Fwxhelp%2F7292e3ab-4bdc-4f40-813f-8657e78035581675310603630.pdf'
    // let path = 'http://14.1.1.1:8088/file/downloadFile?id=140'
    if (!url) {
      url =
        'https%3A%2F%2Fchcms.xinxinqushi.com%2Fwxhelp%2F7292e3ab-4bdc-4f40-813f-8657e78035581675310603630.pdf'
    }

    const fileUrl = '/pdf-viewer/web/viewer.html'
    // 生产环境下
    if (process.env.NODE_ENV === 'production') {
      this.pdfurl = fileUrl + '?file=' + decodeURIComponent(url)
    } else {
      // 开发环境
      this.pdfurl = fileUrl + '?file=' + decodeURIComponent(url)
    }
  },
  computed: {},
}
</script>
<style lang="scss" scoped>
.pdf-viewer {
  height: 100vh;
}
</style>
